package cn.mju.tankfighterbackend.entity

import jakarta.persistence.ElementCollection
import jakarta.persistence.Entity
import jakarta.persistence.FetchType
import lombok.Data
import lombok.EqualsAndHashCode
import lombok.ToString


@EqualsAndHashCode(callSuper = true)
@Data
@Entity //@ApiModel(value ="管理员")

class CustomerUser : EntityBase() {
    var userName: String? = null
    var password: String? = null


    /** 权限
     */
    @ToString.Exclude
    @ElementCollection(fetch = FetchType.EAGER)
    var authorities: MutableSet<String> = HashSet()




    fun addAuthorities(strings: List<String>): CustomerUser {
        authorities.addAll(strings)
        return this
    }


    fun addAuthority(str: String): CustomerUser {
        authorities.add(str)
        return this
    }

    override fun toString(): String {
        return "CustomerUser(userName=$userName,id=${super.id}) "
    }

    val authoritiesStrings: Array<String>
        get() = authorities.toTypedArray()

}